Conversation
There was a problem hiding this comment.
yeah, it's look like ok. But i think, you must be include QSerializer AND src/qserializer.h to add_library and SHARED instead of INTERFACE for correct automoc generating by cmake.
So, if use it like this, i see this way to include QSerializer to external CMake-based project
External CMake-based project CMakeLists.txt:
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/QSerializer)
target_link_libraries(${PROJECT_NAME} QSerializer)
In this case you have opportunity include QSerializer file to your code like this:
#include <QSerialzier>
change add_library(...) and i will merge this PR to master brunch.
And next, i think we have need move QSerialzier include file to some "include" folder. Cause if include QSerializer project to CMake like this - it is will be include all files from QSerializer folder, incluing examples folder, LICENSE and other.
i suggest my CMakeLists.txt version:
cmake_minimum_required(VERSION 3.14)
project(QSerializer LANGUAGES CXX)
set(
HEADER_FILES
"QSerializer"
"src/qserializer.h"
)
add_library(${PROJECT_NAME} SHARED ${HEADER_FILES})
include_directories(${Qt${QT_VERSION_MAJOR}Core_INCLUDE_DIRS})
if (NOT Qt6_FOUND)
find_package(Qt5 COMPONENTS Core REQUIRED Xml REQUIRED)
endif()
target_include_directories(${PROJECT_NAME} INTERFACE ${${PROJECT_NAME}_SOURCE_DIR})
target_link_libraries(${PROJECT_NAME} INTERFACE Qt::Core Qt::Xml)
and after that in external CMakeLists.txt:
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/QSerializer)
target_link_libraries(${PROJECT_NAME} QSerializer)
it should be work correct
At the moment this doesn't support installation (e.g. to
/usr/include/) but it should be usable as a git submodule.The include path is
<QSerializer>which I'm not sure about (since it might be mistaken for an official qt header) so if that's a problem I'll need to think of a workaround.